define(function(require, exports){
	var pubjs	= require('pubjs');
	var popwin	= require('@base/dialog').base;

	var Info = popwin.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'title': LANG(''),
				'width': 800,
				'showFoot': true,
				'param': null,
				'class': '',
				'silence': false,
				'size': 'l',
				'buttons': ['cancel', null]
			});

			this.Super('init', arguments);
		},
		afterBuild:function() {
			this.Super('afterBuild', arguments);
			this.createAsync('grid', 'campaign/grid/diagnosis.info');
			this.createAsync('creative', 'campaign/action/diagnosis.main', function(mod) {
				mod.hide();
			});
		}
		,onGridDataLoad: function( ev )
		{
			if(!this.$isCreative)
			{
				var isCampainSet = this.$module && this.$module == 'campaign_set';
				this.$.grid
					.toggleColumn(['pass', 'filter', 'passRate'], isCampainSet)
					.toggleColumn(['detail'], !isCampainSet);
			}

			return false;
		}
		,load: function(id)
		{
			if(id)
			{
				if(this.$isCreative)
				{
					this.$.creative.reset().setTitle(LANG('活动诊断')).load(id);
				}
				else
				{
					this.$.grid.setParam({_id: id, module: this.$module}).reload();
				}
			}

			return this;
		}
		,setModule(module)
		{
			this.$module = module;
			if(module == 'creative')
			{
				this.$isCreative = true;
				this.$.grid.hide();
				this.$.creative.show();
			}
			else
			{
				this.$isCreative = false;
				this.$.grid.show();
				this.$.creative.hide();
			}
			return this;
		}
	});

	exports.info = Info;

});